package com.example.tests;

import java.util.concurrent.TimeUnit;

import org.junit.Before;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;

import ru.esteru.selenium.factory.WebDriverFactory;

import com.eample.pages.InternalPage;
import com.eample.pages.LoginPage;
import com.eample.pages.MyPageFactory;
import com.eample.pages.UserPage;

public class TestBase {
	protected WebDriver driver;
	protected WebDriverWait wait;
	protected String baseUrl;
	protected LoginPage LoginPage;
	protected InternalPage samPage;
	protected UserPage userPage;

	@Before
	public void setUp() throws Exception {
		driver = WebDriverFactory.getDriver(DesiredCapabilities.firefox());
		baseUrl = "http://localhost/";
		wait = new WebDriverWait(driver, 10);
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	}

	public LoginPage goToMainPage() {
		// open main page
		driver.get(baseUrl + "/php4dvd-2.0/php4dvd/");
		LoginPage = PageFactory.initElements(driver, LoginPage.class);
		samPage = PageFactory.initElements(driver, InternalPage.class);
		userPage = PageFactory.initElements(driver, UserPage.class);
		return MyPageFactory.getPage(driver, com.eample.pages.LoginPage.class);
	}

}
